﻿using System.Collections.Generic;
using HRC.Library.DBAccessLayer.Parameters;
using HRC.Library.EntityLibrary.EntityOperations;
using Lehnet.BusinessLayer.Interfaces;
using Lehnet.Models;

namespace Lehnet.BusinessLayer
{
    public class MusteriPersonelBusiness : IMusteriPersonelBusiness
    {
        public MusteriPersonel Login(MusteriPersonel musteriPersonel)
        {
            return
                EntityManager.Load<MusteriPersonel>(string.Format(" where KullaniciAdi='{0}' and Sifre='{1}'", musteriPersonel.KullaniciAdi, musteriPersonel.Sifre));
        }

        public List<MusteriPersonel> LoadAllMusteriPersonelByMusteriId(int musteriId)
        {
            return EntityManager.LoadAll<MusteriPersonel>(new HRCParameter("MusteriId", musteriId, HRCParameterType.INT));
        }

        public MusteriPersonel LoadMusteriPersonelById(int musteriPersonelId)
        {
            return EntityManager.Load<MusteriPersonel>(" where Id=" + musteriPersonelId);
        }

        public void SaveOrUpdate(MusteriPersonel musteriPersonel)
        {
            if (musteriPersonel.Id == 0)
            {
                EntityManager.Insert(musteriPersonel);

            }
            else
            {
                EntityManager.Update(musteriPersonel);
            }
        }

        public void Delete(int musteriPersonelId)
        {
            EntityManager.Delete<Models.MusteriPersonel>(new HRCParameter("Id", musteriPersonelId, HRCParameterType.INT));
        }
    }
}
